%h1 Repositories

.repositories
  - if @repositories
    - if @repositories.empty?
      %h2 You Haven't Setup Any Repositories Yet

    - @repositories.each do |repo|
      .repository
        %h3= "#{repo.name} : #{repo.branch}"
        %p
          .panel
            %a{:href=>"#repo-#{repo.id}", :rel=>'facebox'} change
            or 
            %form{:action=>"repositories/#{repo.id}", :method=>:post}
              %input{:type=>:hidden, :name=>:_method, :value=>:delete}
              %input.delete{:type=>:submit, :value=>:delete}

          .panel{:style=>'display:none', :id=>"repo-#{repo.id}"}
            %form{:action=>"repositories/#{repo.id}", :method=>:post}
              = haml :'repositories/form', :locals => { :repository => repo }
              %input{:type=>:hidden, :name=>:_method, :value=>:put}
              %br
              %input{:type=>:submit, :value=>:update, :style=>'margin-top:15px'}

    .new-repository-link.action
      %a{:href=>'#new-repository', :rel=>'facebox'} New Repository

#new-repository{:style=>'display:none'}
  %h2 Add a new repository
  %form{:action=>'repositories', :method=>:post}
    =haml :'repositories/form'
    %input{:type=>:hidden, :name=>:_method, :value=>:post}
    %input{:type=>:submit, :value=>:create}

:javascript
  $('.panel .delete').click(function(e) {
    alert("Are you sure you want to do this? It can't be undone.") });
